<template>
	<view class="user-info">
		<view class="avatar">
			<u-avatar src="../../static/image/logo.png" size="194"></u-avatar>
		</view>

		<view class="form">
			<u-form :model="form" ref="uForm" class="swiper-box">
				<!-- 昵 -->
				<u-form-item prop="name" label-width=120 label="昵称">
					<u-input v-model="form.name" placeholder="请输入您的昵称" />
				</u-form-item>
				<!-- 性别 -->
				<u-form-item prop="sex" label-width=120 label="性别">
					<u-input v-model="form.sex" placeholder="请输入" />
				</u-form-item>
				<!-- 年龄 -->
				<u-form-item prop="age" label-width=120 label="年龄">
					<u-input v-model="form.age" placeholder="请输入您的年龄" />
				</u-form-item>
			</u-form>
			<u-button type="primary" class="btn" @click="submit">修改资料</u-button>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					name: uni.getStorageSync('username'),
					sex: '男',
					age: '14',
				},
			}
		},
		methods: {
			submit() {
				debugger
				uni.setStorageSync('username', this.form.name)
				this.$refs.uToast.show({
					title: '修改成功',
					type: 'success',
					url: 'pages/mine/mine',
					isTab:true
				})
			}
		}
	}
</script>

<style lang="scss">
	.user-info {
		.avatar {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 320rpx;
			background-color: $base-color;
		}

		.form {
			display: flex;
			flex-flow: column;
			width: 100%;
			height: 560rpx;
			padding: 20rpx 50rpx 0 50rpx;

			.u-form-item {
				display: flex;
				justify-content: center;
				height: 80rpx;
				margin-top: 20rpx;
				background-color: #f8f6fc;
			}

			.btn {
				margin-top: 60rpx;
				width: 85%;
				border-radius: 30rpx;
			}
		}


	}
</style>
